Skip to content

test: improve code coverage to 91%#17

Merged
bensabic merged 8 commits intomainfrom
test/improve-code-coverage
Feb 22, 2026
Merged

test: improve code coverage to 91%#17
bensabic merged 8 commits intomainfrom
test/improve-code-coverage

Conversation

@bensabic
Copy link
Member

  • Configure @vitest/coverage-v8 with coverage reporting (pnpm test:coverage)
  • Add unit tests for previously untested modules: token-storage, csv, index, program
  • Add comprehensive tests for command modules: members, records, auth (login OAuth flow), apps, custom-fields, permissions, prices, tables
  • Cover error handlers, optional fields, branch conditions, and edge cases across all modules
  • Update ARCHITECTURE.md and AGENTS.md to document new test files and coverage tooling
  • Statements: ~62% → 91.5%, Branches: ~44% → 74%, Tests: 169 → 307

Cover the two library modules that had no test coverage:
- token-storage: saveTokens, loadTokens, clearTokens, getValidAccessToken,
  getAppId, JWT parsing, token refresh, and expiry buffer logic
- csv: flattenObject, unflattenObject, readCsvFile, readInputFile,
  writeOutputFile, and edge cases (empty input, nested objects, arrays)
Add @vitest/coverage-v8 and configure coverage in vitest.config.ts
to report on src/**/*.ts (excluding types.ts). Adds text and html
reporters, a test:coverage script, and gitignores the coverage dir.
Cover previously untested subcommands and branches:
- members: list pagination/--all/--order/empty, create with all options,
  update --email/no-options, export, import (success/skip/failure/fields),
  find (field/plan/combined), stats, bulk-update (run/dry-run/missing-id/email),
  bulk-add-plan (no-plan/dry-run/unknown-filter)
- records: query, export (default/custom path), import (success/skip/failure/
  data-prefix), bulk-update (run/dry-run/missing-id), bulk-delete
  (run/dry-run/no-matches)
Cover the CLI entry point behaviors:
- Banner prints to stderr by default
- Banner suppressed with --quiet and -q flags
- NO_COLOR set from --no-color argv or NO_COLOR env
- All 13 commands registered via addCommand
- parseAsync called, default action shows help
Cover all branches of the login flow including successful OAuth,
authorization errors, missing code/state, state mismatch, non-callback
404 paths, registration failure, and error without description.
…rices, and tables

Cover error handlers, optional fields, and branch conditions across all
five command modules to improve statement coverage from 70-80% to 95-100%.
Test program name, description, version, usage, registered options,
configureHelp reordering, and preAction hook for --live/--sandbox flags.
Add new test files to project tree listing, document test:coverage
command, and note @vitest/coverage-v8 in dev dependencies.
@bensabic bensabic merged commit ba7a81b into main Feb 22, 2026
1 check passed
@bensabic bensabic deleted the test/improve-code-coverage branch February 22, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant